/**
 * 
 */
package qualification2010;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

/**
 * @author Coddy created on 2010-5-7
 * 
 */
public class ReverseWords
{
	static String largeInput = "B-large-practice.in";
	static String largeOutput = "B-large-practice.out";
	static String smallInput = "B-small-practice.in";
	static String smallOutput = "B-small-practice.out";

	/**
	 * @param args
	 */
	public static void main(String[] args)
	{
		try
		{
			BufferedReader bf = new BufferedReader(new FileReader(largeInput));
			BufferedWriter bw = new BufferedWriter(new FileWriter(largeOutput));
			int n = Integer.parseInt(bf.readLine());

			for (int i = 1; i <= n; i++)
			{
				String line = bf.readLine();
				StringTokenizer tokenizer = new StringTokenizer(line);
				List<String> list = new ArrayList<String>();
				while (tokenizer.hasMoreElements())
				{
					String string = (String) tokenizer.nextElement();
					list.add(string);
				}
				bw.write("Case #" + i + ": ");
				for (int j = list.size() - 1; j > 0; j--)
				{
					bw.write(list.get(j));
					bw.write(" ");
				}
				bw.write(list.get(0));
				bw.write("\n");
				bw.flush();

			}
		} catch (FileNotFoundException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NumberFormatException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
